﻿namespace order.Config
{
    public static class ConsulRegisterExtensions
    {
        public static ConsulRegisterOptions GetConsulRegisterOptions(this IConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var serviceConfig = new ConsulRegisterOptions
            {
                ServiceDiscoveryAddress = configuration.GetValue<Uri>("ConsulRegisterOptions:serviceDiscoveryAddress"),
                ServiceAddress = configuration.GetValue<Uri>("ConsulRegisterOptions:serviceAddress"),
                ServiceName = configuration.GetValue<string>("ConsulRegisterOptions:serviceName")
           
            };

            return serviceConfig;
        }
    }
}
